

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>添加banner</title>
  {include file="include/top"}
  <style>
    .layui-form-item .layui-input-inline{width: 80%;}
    #LAY_layedit_2{background: #fff;}
  </style>
</head>
<body>

  <div class="layui-form" lay-filter="layuiadmin-form-useradmin" id="layuiadmin-app-form-tags" style="padding: 20px 0 0 0;">
    <div class="layui-form-item">
      <label class="layui-form-label">分类</label>
      <div class="layui-input-inline">
        {include file="include/cid"}
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">标题</label>
      <div class="layui-input-inline">
        <input type="text" name="title" value="{$data.title?$data.title:''}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">封面图</label>
      <div class="layui-input-inline">
        <input type="text" name="img" id="import" value="{$data.img?$data.img:''}" lay-verify="required" placeholder="请输入img" autocomplete="off" class="layui-input">
        <br>
        <img src="{$data.img?$data.img:''}" id="img2" style="max-height: 100px;max-width: 100px;">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">url地址</label>
      <div class="layui-input-inline">
        <input type="text" name="title2" value="{$data.title2?$data.title2:''}" lay-verify="required" placeholder="请输入http://taobao.com 或 /pages/baike/v?id=5" autocomplete="off" class="layui-input">
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label">备注</label>
      <div class="layui-input-inline">
        <textarea id="content" name="content" lay-verify="content" autocomplete="off" class="layui-textarea" style="display: none;">{$data.content?$data.content:''}</textarea>
      </div>
    </div>

  </div>

  {include file="include/js"}
  <script>
    layui.config({
      base: '/layuiadmin/' //静态资源所在路径
    }).extend({
      index: 'lib/index' //主入口模块
    }).use(['index','form','upload','layedit'],function () {
      var $=layui.$;
      var form=layui.form;
      var upload = layui.upload
      var layedit = layui.layedit;

      // 图片接口放到建立编辑器前面，否则无效
      layedit.set({
        uploadImage: {
          url: '/includes/upload', //接口url
          type: 'post' //默认post
        }
      });
      // 设置编辑器
      layedit.build('content', {
        height: 500 //设置编辑器高度
        ,background:"#ffffff"
      });

      var index = layedit.build('content'); //建立编辑器
      form.verify({ // 这里就是把富文本数据同步到<textarea>中
        content: function (value) {
          return layedit.sync(index);
        }
      });

      upload.render({
        elem: '#import'
        ,url: '/includes/upload' //改成您自己的上传接口
        ,before:function () {
          $load = layer.load();
        }
        ,auto: true
        ,exts: 'jpg|png' //只允许上传压缩文件
        //,multiple: true
        // ,bindAction: '#test9'
        ,done: function(res){
          layer.close($load);
          if(res.code==1){
            layer.msg(res.msg);
          }else{
            layer.msg('上传成功');
            $("#import").val(res.data.src);
            $("#img2").attr("src",res.data.src);
          }
        },error:function () {
          layer.close($load)
        }
      });


    });
  </script>
</body>
</html>